package com.faith.mahounoshoujo.game.event.in;

import java.util.concurrent.ConcurrentLinkedQueue;

/**
 *
 * @author Faith
 */
public class GameIncomingEventQueue {
    private ConcurrentLinkedQueue<GameIncomingEvent> queue;

    private volatile static GameIncomingEventQueue instance;

    public GameIncomingEventQueue() {
           queue = new ConcurrentLinkedQueue<GameIncomingEvent>();
    }

    public static GameIncomingEventQueue getInstance(){
        if(instance == null){
            synchronized (GameIncomingEventQueue.class){
                if(instance == null){
                    instance = new GameIncomingEventQueue();
                }
            }
        }
        return instance;
    }

    public void add(GameIncomingEvent event){
        queue.add(event);
    }

    public GameIncomingEvent process(){
        return queue.poll();
    }
}
